package cn.timelost.elasticsearch.controller;

import cn.timelost.elasticsearch.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author JiangYiFan
 * @date 2021/5/4
 */
@RestController
public class MovieController {

    @Autowired
    private MovieService movieService;

    @GetMapping("/search/{searchName}")
    public List<Map<String, Object>> search(@PathVariable("searchName") String searchName) throws Exception {
        return movieService.search(searchName);
    }

    @GetMapping("/list")
    public List<Map<String, Object>> list() throws Exception {
        return movieService.searchAll();
    }

    @GetMapping("/type")
    public List typeList() throws Exception {
        return movieService.tagList();
    }

    @GetMapping("/list/{type}")
    public List listByType(@PathVariable String type) throws Exception {
        return movieService.searchByType(type);
    }
}
